<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="null"
    cancelText="关闭">

    <table id="table_report" class="table table-striped table-bordered table-hover">

      <tr>
        <td style="width:90px;text-align: center;padding-top: 70px;">基本信息:</td>
        <td>
          <p style="float: left;">

            车牌号码：<span id="plateno">
           {{ result.plateno }}
                    </span><br>

            调用方名称：<span id="consumerId">
           {{ result.consumerId }}
                    </span><br>


            返回码：<span id="returnCode">
           {{ result.returnCode }}
                    </span><br>

            返回码说明：<span id="returnMsg">
           {{ result.returnMsg }}
                    </span><br>
            消息号：<span id="msgId">
           {{ result.msgId }}
                    </span><br>
            创建时间：<span id="createTime">
           {{ result.createTime }}
                    </span><br>
          </p>
        </td>
      </tr>


      <tr>
        <td style="text-align: center;" colspan="10">
          <a-button type="primary" @click="close">关闭</a-button>
        </td>
      </tr>
    </table>

  </a-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"

  export default {
    name: "B2cLicenseplatePaymentQueryV1LogModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        result: {},
        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        },
        url: {
          add: "/b2cpaymentpay/b2cLicenseplatePaymentQueryV1Log/add",
          edit: "/b2cpaymentpay/b2cLicenseplatePaymentQueryV1Log/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        if(record.returnCode === 0)
        {
          record.returnCode ='交易成功'
        }
        else {
          record.returnCode = '交易失败'
        }
        Object.assign(this.result, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.close()
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            //时间格式化

            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })



          }
        })
      },


      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>